import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
import { Popup } from "devextreme-react";
import React, { useImperativeHandle, useRef, useState } from "react";
const CpasTableChangePupop = React.forwardRef((props, ref) => {
    const [visible, setVisible] = useState(false);
    const popupRef = useRef(null);
    const diaParams = useRef();
    // 自定义方法
    useImperativeHandle(ref, () => ({
        show: (params) => {
            diaParams.current = params;
            setVisible(true);
        },
    }));
    const onOk = () => {
        if (diaParams.current?.okCallback) {
            diaParams.current?.okCallback();
        }
        setVisible(false);
    };
    const onCancel = () => {
        setVisible(false);
    };
    return (_jsx(_Fragment, { children: _jsx(Popup, { ref: popupRef, visible: visible, title: diaParams.current?.title, ...props, width: 500, height: 200, dragOutsideBoundary: true, resizeEnabled: true, onHiding: () => setVisible(false), toolbarItems: [
                {
                    widget: "dxButton",
                    toolbar: "bottom",
                    location: "after",
                    options: {
                        text: "否",
                        onClick: () => onCancel(),
                    },
                },
                {
                    widget: "dxButton",
                    toolbar: "bottom",
                    location: "after",
                    options: {
                        text: "是",
                        type: "default",
                        onClick: () => onOk(),
                    },
                },
            ], contentRender: () => _jsx("div", { children: diaParams.current?.content }) }) }));
});
export default CpasTableChangePupop;
